package com.cykj.faceledtv.network.download;

import java.io.IOException;


import okhttp3.Interceptor;
import okhttp3.Response;

/**
 * 下载文件拦截器
 *
 * @author jzh
 * @date 2019/01/19 09:31
 */
public class DownloadInterceptor implements Interceptor {
    private DownLoadListener downloadListener;

    public DownloadInterceptor(DownLoadListener downloadListener) {
        this.downloadListener = downloadListener;
    }

    @Override
    public Response intercept(Chain chain) throws IOException {
        Response response = chain.proceed(chain.request());
        return response.newBuilder().body(
                new DownloadResponseBody(response.body(), downloadListener)).build();
    }
}
